<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>学生信息</title>
	<meta name="decorator" content="default"/>
<script src="${ctxStatic }/jquery-file-upload/js/jquery.fileupload.js"></script>
<script src="${ctxStatic }/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<script src="${ctxStatic}/front/js/jquery-ui.min.js"></script>
<script src="${ctxStatic}/front/js/myValidate.js"></script> 
 
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate(
					{
						rules : {
							name : {
								required: true,
								maxlength : 4
							}, 
							sex : {
								required: true
							}, 
							schoolId: {
								required: true
							}, 
							idCard : {
								required: true,
								isIdcard:true
							}, 
							contactPhone : {
								required: true,
								minlength : 10,
								maxlength : 13,
								isPhone:true
							}, 
							email : {
								email : true
							}
						},
						messages : {
							name : {
								required : "请填写学生名称",
								maxlength : '名字少于四个字'
							},schoolId: {
								required: "请选择"
							}, 
							sex : {
								required: "请选择性别"
							}, 
							idCard : {
								required : "请填写",
								minlength : '身份证号长度不能小于18位',
								maxlength : '身份证号长度不能大于18位'
							}, 
							contactPhone : {
								minlength : '固话为区号(3-4位)号码(7-9位)',
								maxlength : '固话最多为12位'
							}, 
							email : {
								email : '请正确填写邮件格式'
							}
						},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		//js -fileupload 需要更新地址
		$(function () {
		    $('#fileupload').fileupload({
		        dataType: 'json',
		        add: function (e, data) {
		            data.context = $('<button/>').text('Upload')
		                .appendTo(document.body)
		                .click(function () {
		                    $(this).replaceWith($('<p/>').text('Uploading...'));
		                    data.submit();
		                });
		        },
		        done: function (e, data) {
		            data.context.text('Upload finished.');
		        }
		    });
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/dd/ddStudent/">学生列表</a></li>
		<li class="active"><a href="${ctx}/dd/ddStudent/form?id=${ddStudent.id}">学生<shiro:hasPermission name="dd:ddStudent:edit">${not empty ddStudent.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="dd:ddStudent:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="ddStudent" action="${ctx}/dd/ddStudent/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>学生姓名：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="50" class="input-xlarge " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>所属学校：</label>
			<div class="controls">
			 <form:select path="schoolId" class="input-mini form-control required ">
			                    <form:option value="">请选择</form:option>
								<form:options items="${fns:getSchoolNameList()}" itemLabel="name"
									itemValue="id" htmlEscape="false" />
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><b style="color: red; font-size: large">*</b>性别：</label>
			<div class="controls">
				<form:radiobuttons path="sex"
								items="${fns:getDictList('sex')}" itemLabel="label"
								itemValue="value" htmlEscape="false" class="" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>出生日期：</label>
			<div class="controls">
				<input name="birthdate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate " required="required"
					value="<fmt:formatDate value="${ddStudent.birthdate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>出生地：</label>
			<div class="controls">
				<form:input path="birthplace" htmlEscape="false" maxlength="50" class="input-xlarge " required="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>籍贯：</label>
			<div class="controls">
				<form:input path="nativeplace" htmlEscape="false" maxlength="50" class="input-xlarge " required="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">民族：</label>
			<div class="controls">
				<form:input path="nation" htmlEscape="false" maxlength="50" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">国籍：</label>
			<div class="controls">
				<form:input path="nationality" htmlEscape="false" maxlength="50" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>健康状况：</label>
			<div class="controls">
				<form:select path="health" class="input-mini form-control required ">
				                <form:option value="">请选择</form:option>		
								<form:options items="${fns:getDictList('health')}" itemLabel="label"
								itemValue="value" htmlEscape="false" />
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">政治面貌：</label>
			<div class="controls">
				<form:select path="political" class="input-mini form-control ">
				                <form:option value="">请选择</form:option>		
								<form:options items="${fns:getDictList('political')}" itemLabel="label"
								itemValue="value" htmlEscape="false" />
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">血型：</label>
			<div class="controls">
				<form:select path="bloodType" class="input-mini form-control ">
				                <form:option value="">请选择</form:option>		
								<form:options items="${fns:getDictList('bloodType')}" itemLabel="label"
								itemValue="value" htmlEscape="false" />
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">照片：</label>
			<div class="controls">
				<%-- <form:input path="photo" htmlEscape="false" maxlength="100" class="input-xlarge "/> --%>
				<%-- <table>
					<tr>
						<td><form:input path="photo" htmlEscape="false"
								readonly="true" /></td>
						<td><img id="photo" src="${ddStudent.photo}"
							style="max-width:500px; max-height:100px;" /></td>
						<!-- 此处路径需要更新 -->
					</tr>
				</table> --%>
				<input id="fileupload" type="file" name="files" multiple>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>户口所在地：</label>
			<div class="controls">
				<form:input path="registeredResidence" htmlEscape="false" maxlength="100" class="input-xlarge " required="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>户口性质：</label>
			<div class="controls">
				<form:select path="registeredType" class="input-mini form-control required ">
				                <form:option value="">请选择</form:option>		
								<form:options items="${fns:getDictList('registeredType')}" itemLabel="label"
								itemValue="value" htmlEscape="false" />
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label"><b style="color: red; font-size: large">*</b>身份证号码：</label>
			<div class="controls">
				<form:input path="idCard" htmlEscape="false" maxlength="20" class="input-xlarge"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>现住地址：</label>
			<div class="controls">
				<form:input path="liveAddress" htmlEscape="false" maxlength="100" class="input-xlarge " required="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			通信地址：</label>
			<div class="controls">
				<form:input path="mailingAddress" htmlEscape="false" maxlength="100" class="input-xlarge " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">家庭地址：</label>
			<div class="controls">
				<form:input path="homeAddress" htmlEscape="false" maxlength="100" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>联系电话：</label>
			<div class="controls">
				<form:input path="contactPhone" placeholder="例如:0000-00000000" htmlEscape="false" maxlength="50" class="input-xlarge" required="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			邮编：</label>
			<div class="controls">
				<form:input path="zipCode" htmlEscape="false" maxlength="20" class="input-xlarge " />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			电子邮箱：</label>
			<div class="controls">
				<form:input path="email" htmlEscape="false" maxlength="50" class="input-xlarge " />
			</div>
		</div>
		
		
		<div class="form-actions">
			<shiro:hasPermission name="dd:ddStudent:edit">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>